package com.health.pojo;


import java.util.Arrays;

public class HealthAttributes {
    private int attributeId;      // 健康项属性
    private String attributeName; // 属性名
    private String attributeScope; // 属性正常范围


    // 独立关系值
    private Double attributeValue;   // 每个人的属性值
    private String searchExamineDate;


    // 通过Attribute得出结果(构造方法计算得出)
    private int consequence;

    private boolean checked = false;//套餐添加中的选中状态

    public boolean getChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public String getSearchExamineDate() {
        return searchExamineDate;
    }

    public void setSearchExamineDate(String searchExamineDate) {
        this.searchExamineDate = searchExamineDate;
    }


    @Override
    public String toString() {
        return "HealthAttributes{" +
                "attributeId=" + attributeId +
                ", attributeName='" + attributeName + '\'' +
                ", attributeScope='" + attributeScope + '\'' +
                ", attributeValue=" + attributeValue +
                ", consequence=" + consequence +
                '}';
    }

    public HealthAttributes() {
    }

    public HealthAttributes(int attributeId, String attributeName, String attributeScope, Double attributeValue, String searchExamineDate) {
        this.attributeId = attributeId;
        this.attributeName = attributeName;
        this.attributeScope = attributeScope;
        this.attributeValue = attributeValue;
        this.searchExamineDate = searchExamineDate;
        // 计算出consequence结果
        String[] attributeScopeAfter = this.attributeScope.split("-");
        double min = Double.parseDouble(attributeScopeAfter[0]);
        double max = Double.parseDouble(attributeScopeAfter[1]);
        if (attributeValue > max) {
            this.setConsequence(1);    // 1表示偏高
        } else if (attributeValue < min) {
            this.setConsequence(-1);  // -1表示偏低
        } else {
            this.setConsequence(0);   // 0表示正常
        }
    }

    public HealthAttributes(int attributeId, String attributeName, String attributeScope) {
        this.attributeId = attributeId;
        this.attributeName = attributeName;
        this.attributeScope = attributeScope;
    }


    public int getAttributeId() {
        return attributeId;
    }

    public void setAttributeId(int attributeId) {
        this.attributeId = attributeId;
    }

    public String getAttributeName() {
        return attributeName;
    }

    public void setAttributeName(String attributeName) {
        this.attributeName = attributeName;
    }

    public String getAttributeScope() {
        return attributeScope;
    }

    public void setAttributeScope(String attributeScope) {
        this.attributeScope = attributeScope;
    }

    public Double getAttributeValue() {
        return attributeValue;
    }

    public void setAttributeValue(Double attributeValue) {
        this.attributeValue = attributeValue;
    }

    public int getConsequence() {
        return consequence;
    }

    public void setConsequence(int consequence) {
        this.consequence = consequence;
    }
}
